{template 'common/header'}
<ul class="we7-page-tab">
	<li class="active"><a href="{php echo $this->createWeburl('smsset', array('op' => 'display'))}">短信平台</a></li>
</ul>
<div class="main" id="smsset">
	<div class="alert alert-warning">短信使用"阿里云短信服务"。登陆进入控制台，在产品与服务->云计算基础服务->云通信中选择短信服务，并开启。<a href="http://www.aliyun.com/" target="_blank">立即申请</a></div>
	<div class="we7-form">
		<div class="form-group">
			<label class="control-label col-sm-2">开启短信功能</label>
			<div class="form-controls col-sm-8 we7-padding-bottom">
				<input id="sms_status-1" type="radio" v-model="sms.status" value="2"/>
				<label for="sms_status-1" >开启</label>
				<input id="sms_status-2" type="radio" v-model="sms.status" value="1"/>
				<label for="sms_status-2">关闭</label>
			</div>
		</div>
		<div class="form-group">
			<label for="" class="control-label col-sm-2">AccessKeyId</label>
			<div class="form-controls col-sm-8">
				<input type="text" class="form-control" v-model="sms.appkey">
				<span class="help-block">请填写AccessKeyId.</span>
			</div>
		</div>
		<div class="form-group">
			<label for="" class="control-label col-sm-2">AccessKeySecret</label>
			<div class="form-controls col-sm-8">
				<input type="text" class="form-control" v-model="sms.appsecret">
				<span class="help-block">请填写AccessKeySecret.</span>
			</div>
		</div>
		<div class="form-group">
			<label for="" class="control-label col-sm-2">短信签名</label>
			<div class="form-controls col-sm-8">
				<input type="text" class="form-control" v-model="sms.sign">
				<span class="help-block">请填写短信签名.</span>
			</div>
		</div>
		<button class="btn btn-primary col-lg-1" @click="smssetSubmit">提交</button>
	</div>
</div>
<script type="text/javascript">
	require({
		paths: {
			'vue': 'https://unpkg.com/vue@2.2.6/dist/vue',
		}
	})
	var sms_info = {php echo json_encode($sms_info)};
	require(['vue'], function(Vue) {
		var app = new Vue({
			el: '#smsset',
			data: {
				sms: sms_info
			},
			methods: {
				smssetSubmit() {
					$.post("{php echo $this->createWeburl('smsset', array('op' => 'post'));}", {params : this.sms}, function(data) {
						data = $.parseJSON(data);
						if (data.message.errno != 0) {
							util.message(data.message.message, '', 'error');
						} else {
							util.message('设置成功', data.redirect, 'success');
						}
					});
				}
			}
		});
	});
</script>
{template 'common/footer'}